package com.example;

import jakarta.servlet.ServletContextAttributeEvent;
import jakarta.servlet.ServletContextAttributeListener;
import jakarta.servlet.annotation.WebListener;

@WebListener
public class MyServletContextAttributeListener implements ServletContextAttributeListener {

    @Override
    public void attributeAdded(ServletContextAttributeEvent event) {
        System.out.println("监听到往ServletContext对象中存数据了");
    }

    @Override
    public void attributeRemoved(ServletContextAttributeEvent event) {
        System.out.println("监听到从ServletContext对象中移除数据了");
    }

    @Override
    public void attributeReplaced(ServletContextAttributeEvent event) {
        System.out.println("监听到从ServletContext对象中有数据发生变化了");
    }
}
